﻿/*
神秘的表达式 
Time Limit:1000MS  Memory Limit:32768K


Description:
有一个神秘的表达式：ZJU=T。经过研究，发现Z,U,T代表3个不大于1000000的正整数，并
且Z和U经过四则运算可以得到T，那么J代表什么呢？ 
（1） 如果Z加上U等于T，那么J就是“+”；否则
 （2） 如果Z减去U等于T，那么J就是“-”；否则 
 （3） 如果Z乘以U等于T，那么J就是“*”；否则 
 （4） 如果Z整除U等于T，那么J就是“\”。 

Input:
输入数据有N组。每组测试数据给出了Z,U,T。 
Output:
输出数据有N行。每行对应一组测试数据的结果。 
Sample Input:
2
1 1 1
2 2 4
Sample Output:
*
+
*/

#include <iostream>
#define abstract

class Request{
	unsigned _z, _u, _t;
public:
	Request(unsigned z=0u, unsigned u=1u, unsigned t=0u)
		:_z(z), _u(u), _t(t)
	{}
	unsigned getZ()const{return _z;};
	unsigned getU()const{return _u;};
	unsigned getT()const{return _t;};
};
 
abstract class Handler{

public:
	Handler(char op='\0', Handler* next=NULL):_op(op), _next(next){}

	Handler* setNext(Handler *next)
	{
		if(this!=next)
		{
// 			if(NULL!=_next)
// 				delete _next;
			_next=next;
		}
		return this->_next;
	}

	void support(const Request& req)
	{
		if(resolve(req))
			done();
		else if(NULL!=_next)_next->support(req);
		else
			fail();
		
	}

	virtual ~Handler()
	{
// 		if(NULL!=_next)
// 			delete _next;
//		_next=NULL;
	};
protected:
	void fail()const
	{
		std::cout<<"Unhandled exception occured!"<<std::endl;
	}
	void done()const
	{
		std::cout<<_op<<std::endl;
	}
	virtual bool resolve(const Request& req)=0;
	

protected:
	char _op;
	Handler *_next;
};

class NoHandler:public Handler{
public:
	NoHandler():Handler('\0'){}
	virtual bool resolve(const Request& req){return false;}
};

class AddHandler:public Handler{
public:
	AddHandler():Handler('+'){}
	virtual bool resolve(const Request& req)
	{	
/*		_op='+';*/
		return req.getT()==(req.getZ()+req.getU());
	}
};

class SubHandler:public Handler{
public:
	SubHandler():Handler('-'){}
	virtual bool resolve(const Request& req)
	{	
/*		_op='-';*/
		return req.getT()==(req.getZ()-req.getU());
	}
};

class MulHandler:public Handler{
public:
	MulHandler():Handler('*'){}
	virtual bool resolve(const Request& req)
	{	
/*		_op='*';*/
		return req.getT()==(req.getZ()*req.getU());
	}
};

class DivHandler:public Handler{
public:
	DivHandler():Handler('\\'){}
	virtual bool resolve(const Request& req)
	{	
/*		_op='\\';*/
		return req.getT()==(req.getZ()/req.getU());
	}
};

int main(int argc, char* argv[])
{


	Handler* nh=new NoHandler();
	Handler* ah=new AddHandler();
	Handler* sh=new SubHandler();
	Handler* mh=new MulHandler();
	Handler* dh=new DivHandler();	
	ah->setNext(sh)->setNext(mh)->setNext(dh)->setNext(nh);

	unsigned n;
	std::cin>>n;
	while(n--)
	{
		unsigned z, u, t;
		std::cin>>z>>u>>t;
		Request req(z, u, t);
		ah->support(req);
	}

	delete dh;
	delete mh;
	delete sh;
	delete ah;
	delete nh;

	return 0;
}
